﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Stock
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void initSelfMenus()
        {
            string[] array = "操作记录,周统计".Split(',');
            int left = 135;
            int top = 80;
            int num = 1;
            foreach (string key in array)
            {
                if (num > 7)
                {
                    top += 70;
                    left = 135;
                    num = 1;
                }
                this.Controls.Add(this.CreatButton(new System.Drawing.Point(left, top), key.Trim().ToString()));
                left += 110;
                num++;
            }
        }

        private Button CreatButton(Point point, string Text)
        {
            Button btn = new Button();
            btn.Location = point;
            btn.Name = Text;
            btn.Size = new System.Drawing.Size(95, 51);
            btn.TabIndex = 1;
            btn.Text = Text;
            btn.UseVisualStyleBackColor = true;
            btn.BackColor = System.Drawing.Color.FromArgb(167, 224, 250);
            btn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(0, 192, 192);
            btn.ForeColor = System.Drawing.Color.FromArgb(3, 143, 143);
            btn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            btn.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            btn.UseVisualStyleBackColor = false;
            btn.Click += new EventHandler(reload_Click);
            return btn;
        }

        /// <summary>
        /// 点击注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void reload_Click(object sender, EventArgs e)
        {
            try
            {
                string temp = sender.ToString();
                if (sender is Button)
                {
                    temp = (sender as Button).Text;
                }

                if (temp == "操作记录")
                {
                    WinForm.OptInput hfs = new WinForm.OptInput();
                    hfs.ShowDialog();
                    return;
                }
                if (temp == "周统计")
                {
                    WinForm.SumWeek hfs = new WinForm.SumWeek();
                    hfs.ShowDialog();
                    return;
                }

                return;
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //this.chart1.Titles.Add("sdsd");

            //GainGraphBll gainGraphBll = new GainGraphBll();

            //this.chart1.DataSource = gainGraphBll.getList(DateTime.ParseExact("2011-09-22", "yyyy-MM-dd", CultureInfo.InvariantCulture), DateTime.Now);

            //chart1.Series["Series1"].XValueMember = "CalcDate";
            //chart1.Series["Series1"].YValueMembers = "存款";
            ////chart1.Series["Series1"].Label = "#VAL";
            //chart1.Series.Add("Series2");

            //chart1.Series["Series2"].XValueMember = "CalcDate";
            //chart1.Series["Series2"].YValueMembers = "实际金额";
            //chart1.Series["Series2"].Label = "#VAL";

            //chart1.Series.Add("Series3");

            //chart1.Series["Series3"].XValueMember = "CalcDate";
            //chart1.Series["Series3"].YValueMembers = "预期1";
            //chart1.Series["Series3"].Label = "#VAL";

            this.chart1.DataBind();// (gainGraphBll.getList(DateTime.ParseExact("2011-09-22", "yyyy-MM-dd", CultureInfo.InvariantCulture), DateTime.Now));
            //StockInfo si = new SinaStock().GetCurrent("000812");
            //string aaa = new PinYin().GetChineseSpell("中国石化");
            //new Stock.Bl.StockInfoBl().UpdateAllInfo();

            //Stock.WinForm.OptInput my = new WinForm.OptInput();
            //my.Show();

            //List<Decimal> ddd = new List<decimal>();
            //ddd.Add(-1000m);
            //ddd.Add(200m);
            //ddd.Add(-500m);

            //List<Decimal> eee = Stock.Common.CaclCommon.getSumList(ddd);
            //Decimal fff = Stock.Common.CaclCommon.getMinValue(eee);

            //ddd = new List<decimal>();
            //ddd.Add(-1000m);
            //eee = Stock.Common.CaclCommon.getSumList(ddd);
            //fff = Stock.Common.CaclCommon.getMinValue(eee);

            //ddd = new List<decimal>();

            //eee = Stock.Common.CaclCommon.getSumList(ddd);
            //fff = Stock.Common.CaclCommon.getMinValue(eee);

            //try
            //{
            //    Stock.Common.CaclCommon.getStockPriceByDate("2007-08-01", "C:\\金鼎智赢\\T0002\\export\\SH700016.TXT");

            //    decimal sss = Stock.Common.CaclCommon.getStockPriceByDate("2007-08-01", "C:\\金鼎智赢\\T0002\\export\\SH600016.TXT");
            //    Console.WriteLine("2007-08-01  SH600016====> " + sss);
            //    sss = Stock.Common.CaclCommon.getStockPriceByDate("2007-08-04", "C:\\金鼎智赢\\T0002\\export\\SH600016.TXT");
            //    Console.WriteLine("2007-08-04  SH600016====> " + sss);
            //    sss = Stock.Common.CaclCommon.getStockPriceByDate("2011-11-15", "C:\\金鼎智赢\\T0002\\export\\SH600016.TXT");
            //    Console.WriteLine("2011-11-15  SH600016====> " + sss);
            //}
            //catch (Exception ex)
            //{
            //    //MessageBox.Show(ex.Message);
            //}
            //double eee = 0.055;
            //double ccc = eee / 52;
            //double ddd = Math.Pow(1 + ccc, 52);

            //for (; ; )
            //{
            //    if (Math.Round(Math.Pow(1 + ccc, 52), 3) == 1.055)
            //    {
            //        Console.WriteLine("ccc = " + ccc.ToString());
            //        break;
            //    }
            //    else
            //    {
            //        eee = eee - 0.0001;
            //        ccc = eee / 52;
            //    }
            //}

            //double aaa = 0.183 / 365d;
            //double vvv = Math.Pow(1 + aaa, 365);
            //double bbb = Math.Pow(1 - aaa, 365);

            initSelfMenus();
        }
    }
}